import requests
from lxml import etree




# https://www.bidutuijian.com/books/zhongshengshouji/0001.html



url = "https://beijing.zbj.com/search/service?kw=sass&r=2"

res = requests.get(url)

res.encoding = "utf-8"
# with open(f'a.txt',mode="w") as f:
#         f.write(res.text)
# print(res.text)


et = etree.HTML(res.text)

findList = et.xpath('//div[@class="service-card-wrap"]')
# print(findList)
# shop-info text-overflow-line
for item in findList:
    find = item.xpath("./div/div[3]/div[1]/span/text()")
    companyName = item.xpath("./div/a/div[@class='shop-box']/*/div/text()")
    name = item.xpath('./div/div[3]/div[2]/a//text()')  #//  标识a标签下所有的 

    if not find:
        continue
    
    print(companyName)
    print("".join(name), find,"   :",companyName,'\n')
   
    # print([1,2.3,4,5][0],find[0])
# shop-info text-overflow-line